class Solution:
    def numSub(self, s: str) -> int:
        ans = 0
        count = 0
        for string in s + '0':
            if string == '1':
                count += 1
            else:
                res = (count * (1 + count)) // 2
                ans += (res % (10**9 + 7))
                count = 0

        return ans
